import React, { createContext, useContext, useState } from 'react'

const context = createContext()
function ComA() {
  const count = useContext(context)
  return (
    <div>
      this is ComA
      <br />
      app传过来的：{count}
      <br />
      <ComC />
    </div>
  )
}
function ComC() {
  const count = useContext(context)
  return (
    <div>
      this is ComC
      <br />
      app传过来的：{count}
    </div>
  )
}
function App() {
  const [count, setCount] = useState(0)
  return (
    <context.Provider value={count}>
      <div>
        <ComA></ComA>
      </div>
      <button onClick={()=>setCount(count+1)}>+1</button>
    </context.Provider>
  )
}

export default App
